<extend name="Public:base"/>
<a href="{:U}">返回</a>
<block name="content">
    <form action="{:U('Activity/edit')}" method="post" id="formData"  enctype="multipart/form-data">
        <input type="hidden" name="id" value="{$detail['id']}">
        <table>
            <tr>
                <td>标题</td>
                <td><input value="{$detail.title}" id="title" name="title" type="text"></td>
            </tr>
            <tr>
                <td>对象</td>
                <td><select name="type">
                     <option value="1" {$detail['type']==1?'selected':''}>业主</option>
                     <option value="2" {$detail['type']==2?"selected":''}>师傅</option>
                </select></td>
            </tr>
            <tr>
                <td>内容</td>
                <td>
                    <!--加载编辑器的容器-->
                    <script id="edit"  name="content" type="text/plain">{$detail.content|html_entity_decode}</script>
                </td>
            </tr>
            <tr>
                <td>状态</td>
                <td><label><input type="radio" {$detail['status']==1?"checked='ehecked'":''} name="status" value="1">启用</label>
                    <label><input type="radio" {$detail['status']==2?"checked='ehecked'":''} value="2" name="status">停用</label></td>
            </tr>
            <tr>
                <td colspan="2"><input id="my" class="btn btn-primary radius5 btn-sm" onclick="formCheck()" type="button" value="提交"></td>
            </tr>
        </table>
    </form>

</block>
<block name="javascript">
    <!-- 配置文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('edit');
        ue.ready(function () {
            //设置编辑器的内容
            // ue.setContent();
            //获取html内容，返回: <p>hello</p>
            html = ue.getContent();
            //获取纯文本内容，返回: hello
            txt = ue.getContentTxt();
        });
        $('#mybtn').click(function(){
            var ue = UE.getEditor('edit');
            var html = ue.getContent();
            var title=$('#title').val()
            var status=$('input:radio[name="status"]:checked').val();
            console.log(status)
           $.ajax({
                url:"{:U('Activity/add')}",
                type:"post",
                data:{
                    content:html,
                    title:title,
                   status:status,
                },
                success:function(data){
                    location.reload();
                    alert("添加成功")
               }
            });
       });
        function formCheck(){
            $('#formData').ajaxSubmit(function(data){
                console.log(data)
              if(data==0){
                  $.jbox.info('修改失败','提示信息');
              }else{
                  $.jbox.tip("修改成功！", 'loading');
                  window.setTimeout(function () {window.location.href="{:U('Activity/edit&id=').$detail['id']}"; }, 500);
              }
                return false;
            })
        }
    </script>
</block>

